package cn.gson.crm.control;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.gson.crm.model.pojo.OrderResult;
import cn.gson.crm.model.vo.PaymentRecordVO;
import cn.gson.crm.service.prService;

@Controller
public class PrControl {
	@Autowired
	private prService prService;
	
	@GetMapping("/getAllPr")
	@ResponseBody
	public Map getAllPr(int page,int rows) {
		Map map = new HashMap<>();
		Long count = prService.count();
		List<PaymentRecordVO> list = prService.getAllPr(page, rows);
		map.put("total", count);
		map.put("rows", list);
		return map;
	}
	
	@GetMapping("/toPr")
	public String toPr() {
		return "zj/paymentRecord";
	}
	
	@GetMapping("/deletepr")
	@ResponseBody
	public OrderResult deletepr(Long prId) {
		try {
			prService.deletePr(prId);
			return new OrderResult();
		} catch (Exception e) {
			e.printStackTrace();
			return new OrderResult(e);
		}
	}
}
